﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>登录</title>
    <link rel="stylesheet" href="css/style.css">
    
    <link rel="stylesheet" type="text/css" href="~/Content/jqueryeasyui/themes/default/easyui.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="~/Content/jqueryeasyui/themes/icon.css" />
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script src="~/Content/jqueryeasyui/jquery.easyui.min.js"></script>
    <script src="~/Content/jqueryeasyui/locale/easyui-lang-zh_CN.js"></script>
    <link href="~/Content/jqueryeasyui/themes/icon.css" rel="stylesheet" />
    <!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    <style type="text/css">
        .center{
            margin-top:100px;
            margin-left:300px;
            height:300px;
            width:500px;
            background-color:lightblue;
        }
        /*h1{
            text-align:center;
        }*/
        
    </style>
    <script type="text/javascript">
        $(function () {
            $("#btnlogin").click(function () {
                var validate = $("#loginform").form("validate");
                if (validate == false) {
                    return false;
                }
                
                    $.ajax({
                        type: 'post',
                        dataType: 'text',
                        url: '@Url.Content("~/Login/Login")',
                        data: { UserName: $("#username").val(), Password: $("#userpass").val() },
                        success: function (result) {
                            if (result == "Error") {
                                $.messager.alert('提示消息', '登陆失败,用户名或密码错误');
                                
                                $("#username").focus();
                                return;
                            }
                            else if (result == "OK")
                                location.href = "@Url.Content("~/Admin/Index")";
                        },
                        error: function (d, c, e) {
                            //$.ligerDialog.alert('发送系统错误,请与系统管理员联系' + e, '提示消息', 'error');
                            $.messager.alert('提示消息', '发送系统错误,请与系统管理员联系' + e);

                        },
                        //beforeSend: function () {
                        //    //$.ligerDialog.waitting("正在登陆中,请稍后...");
                        //    //$("#btnLogin").attr("disabled", true);
                        //},
                        //complete: function () {
                        //    //$.ligerDialog.closeWaitting();
                        //    $("#btnLogin").attr("disabled", false);
                        //}
                    });
                
                //var postData = $("#loginform").serializeArray();
                //$.post("/Login/Login", postData, function (data) {
                //    if (data == "OK") {
                //        //alert("登录成功！");
                //        //$.messager.show({
                //        //    title: '登录成功！',
                //        //    msg: '消息将在2秒后关闭。',
                //        //    timeout: 2000,
                //        //    showType: 'slide'
                //        //});

                //        window.location.href = "/Admin/Index";
                //    }
                //    else {
                //        //alert(data);
                //        $.messager.alert('警告', data,'error');
                //    }
                //});

            })
        });

    </script>
</head>
<body>
    <div id="win" class="easyui-window" title="登录系统" style="width:300px;height:150px ;margin-left:auto;margin-right:auto" data-options="iconCls:'icon-save',modal:true,minimizable:false,maximizable:false,closable:false,collapsible:false,draggable:false">
        <form id="loginform" method="post">
            <table style="padding-top:15px;padding-left:25px">
                <tr>
                    <td><label for="name">用户名:</label></td>
                    <td><input class="easyui-validatebox" type="text" id="username" name="username" value="admin" required="true"></input></td>
                </tr>
                <tr>
                    <td><label for="email">密 码:</label></td>
                    <td><input class="easyui-validatebox" type="password" id="userpass" name="userpass" value="admin" required="true" /></td>
                </tr>
                <tr>
                    <td>@*<input type="button" id="btnlogin" value="提交">*@</td>
                    <td><a id="btnlogin" href="#" class="easyui-linkbutton" data-options="">登录</a></td>
                </tr>
            </table>

        </form>
    </div>
    
</body>
</html>
